<template>
  <el-dialog
    v-model="dialogVisible"
    :title="title"
    destroy-on-close
    width="800px"
    :draggable="true"
    @closed="close"
  >
    <template #header>
      <div class="my-header">
        <h4>{{ title }}</h4>
        <slot name="headerBtn"></slot>
        <!-- <el-button text @click="close">
          <el-icon class="el-icon--left"><Sort /></el-icon>
          Close
        </el-button> -->
      </div>
    </template>
    <el-scrollbar height="400px" :always="true">
      <slot />
    </el-scrollbar>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="close">取消</el-button>
        <el-button type="primary" @click="onSubmit">
          {{ submitTitle }}
        </el-button>
      </span>
    </template>
  </el-dialog>
</template>
<script setup>
  import { defineProps, defineEmits } from 'vue'
  defineProps({
    dialogVisible: Boolean,
    submitTitle: {
      type: String,
      default() {
        return '确定'
      },
    },
    title: {
      type: String,
      default() {
        return '弹窗'
      },
    },
  })

  const emits = defineEmits(['update:dialogVisible', 'clickSubmit', 'close'])
  function close() {
    emits('update:dialogVisible', false)
    emits('close', false)
  }
  function onSubmit() {
    emits('clickSubmit')
  }

  defineExpose({
    close,
  })
</script>
<style lang="scss" scoped>
  .my-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    h4 {
      // line-height: 18px;
      margin-bottom: 0;
    }
    .icon-rotate {
      transform: rotateY(90deg);
    }
    /* justify-content: space-between; */
  }
</style>
